package com.wxm.common.file.core.enm;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 *      文件Mime类型
 * </p>
 *
 * @author: wxm
 * @Date: 2022/1/22
 */
public enum  FileMimeEnum {
    DOC(".doc","application/msword"),
    DOCX(".docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"),
    RTF(".rtf","application/rtf"),
    XLS(".xls","application/vnd.ms-excel application/x-excel"),
    XLSX(".xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
    PPT(".ppt","application/vnd.ms-powerpoint"),
    PPTX(".pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"),
    PPS(".pps","application/vnd.ms-powerpoint"),
    PPSX(".ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"),
    PDF(".pdf","application/pdf"),
    SWF(".swf","application/x-shockwave-flash"),
    DLL(".dll","application/x-msdownload"),
    EXE(".exe","application/octet-stream"),
    MSI(".msi","application/octet-stream"),
    CHM(".chm","application/octet-stream"),
    CAB(".cab","application/octet-stream"),
    OCX(".ocx","application/octet-stream"),
    RAR(".rar","application/octet-stream"),
    TAR("tar","application/x-tar"),
    TGZ(".tgz","application/x-compressed"),
    ZIP(".zip","application/x-zip-compressed"),
    Z(".z","application/x-compress"),
    WAV(".wav","audio/wav"),
    WMA(".wma","audio/x-ms-wma"),
    WMV(".wmv","video/x-ms-wmv"),
    MP3(".mp3","audio/mpeg"),
    MP2(".mp2","audio/mpeg"),
    MPE(".mpe","audio/mpeg"),
    MPEG(".mpeg","audio/mpeg"),
    MPG(".mpg","audio/mpeg"),
    RM(".rm","application/vnd.rn-realmedia"),
    MID(".mid","audio/mid"),
    MIDI(".midi","audio/mid"),
    RMI(".rmi","audio/mid"),
    BMP(".bmp","image/bmp"),
    GIF(".gif","image/gif"),
    PNG(".png","image/png"),
    TIF(".tif","image/tiff"),
    TIFF(".tiff","image/tiff"),
    JPE(".jpe","image/jpeg"),
    JPEG(".jpeg","image/jpeg"),
    JPG(".jpg","image/jpeg"),
    TXT(".txt","text/plain"),
    XML(".xml","text/xml"),
    HTML(".html","text/html"),
    CSS(".css","text/css"),
    JS(".js","text/javascript"),
    MHT(".mht","message/rfc822"),
    MHTML(".mhtml","message/rfc822")
    ;

    private String type;
    private String mime;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMime() {
        return mime;
    }

    public void setMime(String mime) {
        this.mime = mime;
    }

    FileMimeEnum(String type, String mime){
        this.type = type;
        this.mime = mime;
    }

    private static Map<String,String> mimeMap =  Arrays.stream(values()).collect(Collectors.toMap(FileMimeEnum::getType,FileMimeEnum::getMime));
    public static String getMimeByType(String type){
        return mimeMap.get(type);
    }
}
